function [] = createVideo( name,t, y, ref, fpf )

figure
set(gcf,'Visible','off');
j=1;
writerObj=VideoWriter(name,'MPEG-4');
open(writerObj);
for i=1:length(t)
    hold on
    plot(y(6,1:i),y(5,1:i))
    plot(ref([6],1:i),ref([5],1:i),'-r');
    grid on
    hold off
    title('XY')
    frame=getframe(gcf);
    for k=1:fpf
        %M(j)=frame;
        writeVideo(writerObj,frame);
        j=j+1;
    end
end
close(writerObj);
%movie(M);

%movie2avi(M,name,'compression','xvid');


end

